package org.edu.prj.langton.lefebvre.IHM;

import org.edu.prj.langton.utils.LMatrix;
import org.edu.prj.langton.utils.UIMatrix;

import javax.swing.*;
import java.awt.*;

public class Window extends JFrame {

 
	private static final long serialVersionUID = 1L;
	private LMatrix lMatrix;
    private UIMatrix uiMatrix;

    public Window (LMatrix lMatrix) {
        this(lMatrix, new Dimension(5,5));
    }

    public Window (LMatrix lMatrix, Dimension size) {
        super();
        this.lMatrix = lMatrix;
        uiMatrix = new UIMatrix(lMatrix);
        //change la couleur de la fourmi
        uiMatrix.setCellColor(Color.BLUE);
    
        Container c = new Container();
        getContentPane().add(c);
        c.setLayout(new BorderLayout());
        c.add(uiMatrix, BorderLayout.CENTER);
        setTitle("Fourmi de Langton");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        int w = lMatrix.getNumberOfColumn()*size.width+16;
       
        int h = lMatrix.getNumberOfLine()*size.height+38;
        setSize(w, h);
        System.out.println(getSize());
        setVisible(true);
    }

    public void update () {
        uiMatrix.update(lMatrix);
    }

}
